<template>
  <div class="page-loading-container">
    <div class="loading-content">
      <div class="loading-spinner">
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
      </div>
      <div class="loading-text">
        <p class="loading-title">{{ title || '正在加载' }}</p>
        <p class="loading-subtitle" v-if="subtitle">{{ subtitle }}</p>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  title?: string
  subtitle?: string
}

withDefaults(defineProps<Props>(), {
  title: '正在加载',
  subtitle: ''
})
</script>

<style scoped>
.page-loading-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  width: 100%;
  padding: 80px 20px;
  background: linear-gradient(135deg, #f8fbff 0%, #ffffff 100%);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}

.page-loading-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(64, 158, 255, 0.1),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  position: relative;
  z-index: 1;
}

.loading-spinner {
  position: relative;
  width: 72px;
  height: 72px;
}

.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top-color: #409eff;
  border-radius: 50%;
  animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
  animation-delay: -0.45s;
  border-top-color: #409eff;
  opacity: 1;
  box-shadow: 0 0 20px rgba(64, 158, 255, 0.3);
}

.spinner-ring:nth-child(2) {
  animation-delay: -0.3s;
  border-top-color: #66b1ff;
  opacity: 0.85;
  width: 80%;
  height: 80%;
  top: 10%;
  left: 10%;
  box-shadow: 0 0 15px rgba(102, 177, 255, 0.25);
}

.spinner-ring:nth-child(3) {
  animation-delay: -0.15s;
  border-top-color: #85c1ff;
  opacity: 0.7;
  width: 60%;
  height: 60%;
  top: 20%;
  left: 20%;
  box-shadow: 0 0 10px rgba(133, 193, 255, 0.2);
}

.spinner-ring:nth-child(4) {
  animation-delay: 0s;
  border-top-color: #a0cfff;
  opacity: 0.5;
  width: 40%;
  height: 40%;
  top: 30%;
  left: 30%;
  box-shadow: 0 0 8px rgba(160, 207, 255, 0.15);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.loading-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #303133;
  letter-spacing: 0.3px;
  background: linear-gradient(135deg, #303133 0%, #409eff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-subtitle {
  margin: 10px 0 0;
  font-size: 14px;
  color: #909399;
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* 淡入动画 */
.page-loading-container {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
</style>

